package net.yambal.RTM.Method
{
	import flash.events.EventDispatcher;
	
	import net.yambal.RTM.Event.RestErrorEvent;
	import net.yambal.RTM.Event.RestEvent;
	import net.yambal.RTM.Event.TimelineEvent;
	import net.yambal.RTM.Items.RTMTransaction;
	import net.yambal.RTM.RestWrapper.RestManager;
	import net.yambal.RTM.RestWrapper.RestService;
	
	[Event(name="create", type="net.yambal.RTM.Event.TimelineEvent")]
	public class Timelines extends EventDispatcher
	{
		public function Timelines()
		{
		}
		
		public function create(api_key:String, shared_secret:String, auth_token:String, relay_obj:Object = null):void{
			var p:Object = new Object();
			p.api_key = api_key;
			p.auth_token = auth_token;
			
			var RM:RestManager = new RestManager();
			RM.doMethod(RestService.METHOD_TIMELINES_CREATE, p, this.onCreate, this.onFaultCreate, false, shared_secret);
		}

		private function onFaultCreate(code:Number, massage:String, ro:Object):void{
			// エラー処理
		}

		private function onCreate(result_xml:XML, ro:Object, t:RTMTransaction):void{
			var tl:uint = result_xml.timeline;
			this.dispatchEvent(new TimelineEvent(TimelineEvent.CREATE, tl, ro.parameta.api_key, ro.shared_secret, ro.parameta.auth_token, ro.relay_obj));
		}
	}
}